package com.example.ymm.modules1.service.impl.ms;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.ymm.base.BaseServiceImpl;
import com.example.ymm.model.TableList;
import com.example.ymm.model.YmPageDto;
import com.example.ymm.modules1.entity.my.ms.MsMouldDict;
import com.example.ymm.modules1.mapper.my.ms.MsMouldDictMapper;
import com.example.ymm.modules1.service.dto.ms.MsMouldDictQueryCriteria;
import com.example.ymm.modules1.service.ms.MsMouldDictService;
import com.example.ymm.util.QueryHelpPlus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
@DS("slave2")
public class MsMouldDictServiceImpl extends BaseServiceImpl<MsMouldDictMapper, MsMouldDict> implements MsMouldDictService {

    @Override
    public TableList<MsMouldDict> list(MsMouldDictQueryCriteria criteria, YmPageDto pageDto) {
        IPage<MsMouldDict> page = new Page<MsMouldDict>(pageDto.getPage(),pageDto.getPageSize());
        QueryWrapper predicate = QueryHelpPlus.getPredicate(MsMouldDict.class, criteria);
        predicate.orderByDesc("create_time");
        baseMapper.selectPage(page, predicate);
        TableList<MsMouldDict> tableList=new TableList(page);
        return tableList;
    }

    public List<MsMouldDict> queryAll(MsMouldDictQueryCriteria criteria) {
        QueryWrapper predicate = QueryHelpPlus.getPredicate(MsMouldDict.class, criteria);
        predicate.orderByDesc("create_time");
        List<MsMouldDict> result =baseMapper.selectList(predicate);
        return result;
    }
}
